package com.fh.service.airsys.syscreditaccount;

import java.util.List;

import javax.annotation.Resource;

import com.fh.Enum.EnFinalValue;
import com.fh.util.DateUtil;
import com.fh.util.StringUtils;
import com.fh.util.UuidUtil;
import org.springframework.stereotype.Service;

import com.fh.dao.DaoSupport;
import com.fh.entity.Page;
import com.fh.util.PageData;


@Service("syscreditaccountService")
public class SysCreditAccountService {

	@Resource(name = "daoSupport")
	private DaoSupport dao;
	
	/*
	* 新增
	*/
	public void save(PageData pd)throws Exception{
		pd.put("SYSCREDITACCOUNT_ID", UuidUtil.get32UUID());
		pd.put("SA_ACC",UuidUtil.get32UUID());
		pd.put("SA_STATE", EnFinalValue.ZC.index);
		pd.put("SA_CREATDATE", DateUtil.getTime());
		Integer creditline = (Integer) pd.get("SA_CREDITLINE");
		if(creditline == null){
			pd.put("SA_CREDITLINE",0);
			pd.put("SA_BALANCE",0);
		}
		else {
			pd.put("SA_CREDITLINE",creditline);
			pd.put("SA_BALANCE",creditline);
		}
		dao.save("SysCreditAccountMapper.save", pd);
	}
	
	/*
	* 删除
	*/
	public void delete(PageData pd)throws Exception{
		dao.delete("SysCreditAccountMapper.delete", pd);
	}
	
	/*
	* 修改
	*/
	public void edit(PageData pd)throws Exception{
		dao.update("SysCreditAccountMapper.edit", pd);
	}
	
	/*
	*列表
	*/
	public List<PageData> list(Page page)throws Exception{
		return (List<PageData>)dao.findForList("SysCreditAccountMapper.datalistPage", page);
	}
	
	/*
	*列表(全部)
	*/
	public List<PageData> listAll(PageData pd)throws Exception{
		return (List<PageData>)dao.findForList("SysCreditAccountMapper.listAll", pd);
	}
	
	/*
	* 通过id获取数据
	*/
	public PageData findById(PageData pd)throws Exception{
		return (PageData)dao.findForObject("SysCreditAccountMapper.findById", pd);
	}
	
	/*
	* 批量删除
	*/
	public void deleteAll(String[] ArrayDATA_IDS)throws Exception{
		dao.delete("SysCreditAccountMapper.deleteAll", ArrayDATA_IDS);
	}
	
}

